package com.ea.report.controller;

import com.ea.common.log.LogAnnotation;
import com.ea.common.result.Result;
import com.ea.report.pojo.vo.IsAnalyzedVo;
import com.ea.report.service.ReportResultService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/report/result")
@Slf4j
public class ReportResultController {
    @Resource
    ReportResultService reportResultService;

    @Transactional
    @PostMapping("/saveVibraResult")
    // @LogAnnotation(module = "ReportResultController", operation = "Vibra结果")
    public Result saveVibraResult(String uuid, String resultContent, Boolean isSuccess) {
        reportResultService.saveVibraResult(
                uuid,
                resultContent,
                isSuccess
        );
        return Result.success(null);
    }

    @Transactional
    @PostMapping("/saveShenshiResult")
    // @LogAnnotation(module = "ReportResultController", operation = "Shenshi结果")
    public Result saveShenshiResult(String uuid, String resultContent, Boolean isSuccess) {
        reportResultService.saveShenshiResult(
                uuid,
                resultContent,
                isSuccess
        );
        return Result.success(null);
    }

    @Transactional
    @PostMapping("/isAnalyzed")
    @LogAnnotation(module = "ReportResultController", operation = "判断是否分析")
    public Result<IsAnalyzedVo> isAnalyzed(String uuid) {
        IsAnalyzedVo isAnalyzedVo = reportResultService.isAnalyzed(uuid);
        return Result.success(isAnalyzedVo);
    }

}
